<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <link rel="stylesheet" href="/stylesheets/css/qunit.css" type="text/css" media="screen" />

  <%= js_scripts([
      '/js/libs/jquery.js',
      '/js/test/qunit.js',
      '/js/util.js',
      '/js/c_data.js',
      '/js/key_bindings.js',
      '/js/code_renderer.js',
      ], 'index_test')
  %>

  <script>
  $(document).ready(function() {
  
  // seed c_data
  Data.html               = 'h1 testing';
  Data.html_pre_processor = 'jade';
  Data.css                = 'h1 { color: blue; }';
  Data.css_pre_processor  = 'scss';
  Data.js                 = 'console.log("test");';
  Data.js_pre_processor   = 'none';

  clearCodeRendererRefData = function() {
      CodeRenderer.refHTML   = '';
      CodeRenderer.refHTMLPP = '';
        
      CodeRenderer.refCSS    = '';
      CodeRenderer.refCSSPP  = '';
        
      CodeRenderer.refJS     = '';
      CodeRenderer.refJSPP   = '';
  }

  module("Code Renderer");

  test("Test the Code Renderer useCache function by directly changing HTML", function() {
    clearCodeRendererRefData();

    equal(CodeRenderer.useCache('html'), false, "Since we don't have a reference stored value we should expect this to be false" );

    CodeRenderer.storeRefContent();

    equal(CodeRenderer.useCache('html'), true, "After call to storeRefContent Data and Code Render should be in sync");

    Data.html = 'h2 break cache';
    equal(CodeRenderer.useCache('html'), false, "Should fail after html is changed.");

    // get back in sync
    CodeRenderer.storeRefContent();

    Data.html_pre_processor = 'haml';
    equal(CodeRenderer.useCache('html'), false, "Should fail after html pre processor is changed.");
  });

  test("Test the Code Renderer useCache function by directly changing CSS", function() {
    clearCodeRendererRefData();

    equal(CodeRenderer.useCache('css'), false, "Since we don't have a reference stored value we should expect this to be false" );

    CodeRenderer.storeRefContent();

    equal(CodeRenderer.useCache('css'), true, "After call to storeRefContent Data and Code Render should be in sync");

    Data.css = '* { color: green; }';
    equal(CodeRenderer.useCache('css'), false, "Should fail after css is changed.");

    // get back in sync
    CodeRenderer.storeRefContent();

    Data.css_pre_processor = 'sass';
    equal(CodeRenderer.useCache('css'), false, "Should fail after css pre processor is changed.");
  });

  });
  </script>
  
</head>
<body>
  <h1 id="qunit-header">QUnit example</h1>
 <h2 id="qunit-banner"></h2>
 <div id="qunit-testrunner-toolbar"></div>
 <h2 id="qunit-userAgent"></h2>
 <ol id="qunit-tests"></ol>
 <div id="qunit-fixture">test markup, will be hidden</div>
</body>
</html>